package com.amt.olcacon;

import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        // 模拟数据
        List<Product> products = Arrays.asList(
            new Product(1L, "产品A"),
            new Product(2L, "产品B"),
            new Product(3L, "产品C")
        );
        
        List<Exchange> exchanges = Arrays.asList(
            new Exchange(1L, "交换1", 1L, 2L),  // 产品A -> 产品B
            new Exchange(2L, "交换2", 1L, 3L),  // 产品A -> 产品C
            new Exchange(3L, "交换3", 2L, 1L),  // 产品B -> 产品A
            new Exchange(4L, "交换4", 3L, 2L)   // 产品C -> 产品B
        );
        
        // 构建树状结构
        ExchangeTreeBuilder builder = new ExchangeTreeBuilder();
        TreeNode root = builder.buildExchangeTree(exchanges, products);
        
        // 输出JSON
        try {
            String json = builder.convertToJson(root);
            System.out.println(json);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}